package com.neuedu.yyzx.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.neuedu.yyzx.entity.Checkin;
import com.neuedu.yyzx.mapper.CheckinMapper;
import com.neuedu.yyzx.service.ICheckinService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 入住登记  服务实现类
 * </p>
 *
 * @author dya
 * @since 2021-04-27
 */
@Service
public class CheckinServiceImpl extends ServiceImpl<CheckinMapper, Checkin> implements ICheckinService {


    public boolean updateAll(Checkin checkin) {

        /**
         * update table set aaa = ?
         */
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.set("customer_name", checkin.getCustomerName());
        updateWrapper.set("customer_gender", checkin.getCustomerGender());
        updateWrapper.set("customer_age", checkin.getCustomerAge());
        updateWrapper.set("id_number", checkin.getIdNumber());
        updateWrapper.set("room_id", checkin.getRoomId());
        updateWrapper.set("record_id", checkin.getRecordId());
        updateWrapper.set("checkin_date", checkin.getCheckinDate());
        updateWrapper.set("expire_date", checkin.getExpireDate());
        updateWrapper.set("telephone", checkin.getTelephone());
        updateWrapper.set("families", checkin.getFamilies());
        updateWrapper.set("accompanied_person", checkin.getAccompaniedPerson());
        updateWrapper.set("assess_doctor", checkin.getAssessDoctor());
        updateWrapper.set("resp_doctor", checkin.getRespDoctor());
        updateWrapper.set("carer", checkin.getCarer());
        updateWrapper.set("health_person", checkin.getHealthPerson());
        updateWrapper.set("remarks", checkin.getRemarks());

//        where
        updateWrapper.eq("checkin_id", checkin.getCheckinId());
        int sussess = getBaseMapper().update(checkin, updateWrapper);

        return sussess > 0;
    }

}
